package com.ccctop.cloud.handler;


import com.ccctop.cloud.service.api.TInvestorService;
import com.ccctop.crowd.entity.po.TInvestor;
import com.ccctop.crowd.util.ResultEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TInvestor)表控制层
 *
 * @author makejava
 * @since 2022-02-21 17:23:04
 */
@RestController
public class InvestorController {
    /**
     * 服务对象
     */
    @Resource
    private TInvestorService tInvestorService;

    //查找投资者
    @RequestMapping("/fund/queryInvestors")
    ResultEntity<List<TInvestor>> queryInvestors(@RequestParam("projectId") Integer projectId){
        try{
            List<TInvestor> investors = tInvestorService.queryInvestors(projectId);
            return ResultEntity.successWithData(investors);
        }catch (Exception e){
            return ResultEntity.failed(e.getMessage());
        }
    }
    @RequestMapping("/fund/support")
    ResultEntity<String> supportProject(@RequestBody TInvestor investor){
        try{
            tInvestorService.insert(investor);
            return ResultEntity.successWithoutData();
        }catch (Exception e){
            return ResultEntity.failed(e.getMessage());
        }
    }

}